<template>
    <div>
        <mt-field label="学号" placeholder="请输入学号" v-model="userSid"></mt-field>
        <mt-field label="用户名" placeholder="请输入用户名" v-model="userName"></mt-field>
        <mt-field label="密码" placeholder="请输入密码" type="password" v-model="userPassword"></mt-field>
        <mt-field label="姓名" placeholder="请输入姓名" v-model="name"></mt-field>
        <mt-field label="联系方式" placeholder="请输入联系方式" v-model="phone"></mt-field>
        <mt-button type="default" @click="register">注册</mt-button>
    </div>
</template>

<script>
    import {register} from "../../../api";
    import { Toast } from 'mint-ui';

    export default {
        name: "Register",
        data(){
            return {
                userSid: '',
                userName: '',
                userPassword: '',
                name: '',
                phone: ''
            }
        },
        methods: {
            async register(){
                let data = {
                    userSid: this.userSid,
                    userName: this.userName,
                    userPassword: this.userPassword,
                    name: this.name,
                    phone: this.phone
                }
                let result = await register(data)
                if(result.status == 0){
                    this.$router.push({
                        path: '/app/login'
                    })
                }else {
                    Toast({
                        message: result.msg,
                        duration: 5000
                    });
                }
            }
        }
    }
</script>

<style scoped>

</style>